<!DOCTYPE html>
<html lang='en'>
<meta charset='utf-8'>
<head>
	<title>Weixin后台管理</title>
	<link rel='stylesheet' type='text/css' href='css/bootstrap.min.css'>
	<link rel="shortcut icon" href="img/icon.png">
	<script type='text/javascript' src="js/jquery.js"></script>
	<script type='text/javascript' src="js/bootstrap.min.js"></script>

	<script type="text/javascript">
	
		function toLogin(){
			var phone=document.getElementById("phone").value;
			var password=document.getElementById("password").value;
			
			if ((phone==null||phone=="")||(password==null||password=="")) {
				$("#message").html("账号或者密码为空，请检查后输入");
				return;
			};
			
			$.post("../../shambles/seller/toLogin.do",
				{campusAdmin:phone,password:password},
				function(text){
					var json=eval('('+text+')');
					if (json.status=="success") {
								//将用户名和密码存到cookie
									document.cookie = "campusAdmin="+phone;
									//将当前管理员管理的校区id存到cookie
									//getSellerById获取校区管理员信息
									$.post("../../shambles/seller/getSellerById.do",{
										campusAdmin : phone
										
									},function(data){
										
										console.log('phone='+phone);
										
										//alert(data.seller.type);
										document.cookie = "cityId="+data.seller.cityId;
										
										if(data.sellercampus!=null){
									       document.cookie="campusId="+data.sellercampus.campusId;
										 }
									    
										document.cookie = "type="+data.seller.type;
										console.log(document.cookie);
											//跳转到主页
											top.location.href="admin.html?backurl="+window.location.href;

										
									},"json");

						}else{
                            $("#message").html("对不起，你没有登陆权限！");
						}

				});
		}
		
		
	 function toRegister(){
		 top.location.href="register.html";
	 }	
	</script>
	<style type="text/css">
		.message{
			color: red
		}
		#dropdownMenu1, [role=presentation]{
			width:220px;
		}
	</style>
</head>
<body>
	<div class="container">
		<div class="row">
			<div class="span12">


				<div class="modal show" id="loginModal" aria-hidden="true">
					<div class="modal-header">
						<h2>Weixin管理平台</h2>
					</div>
					<div class="modal-body">
						<form class="form-horizontal" >
							<div class="control-group">
								<label class="control-label" for="phone">用户名</label>
								<div class="controls">
									<input type="text" id="phone" placeholder="账号">
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" for="password">密码</label>
								<div class="controls">
									<input type="password" id="password"
									placeholder="密码">
								</div>
							</div>
						</form>
					</div>
					<div class="modal-footer">
						<div id="message" class="pull-left message"></div>
						<button type="button" class="btn btn-primary" onclick="toLogin();">&nbsp;登录&nbsp;</button>
						<!-- <a href="../manage/user/forgetPassword.do" target="_blank"class="inline">Forget password?</a> -->
					</div>
				</div>
			</div>
		</div>
	</div>
	<script>
	  $("#dropdownMenu1").next().children().children().click(function(){
		$('#dropdownMenu1').text($(this).text());
	  });
	
		$("#phone").focus(function(){
			$("#message").html("");
		});

		$("#password").focus(function(){
			$("#message").html("");
		});

		$('#password').keypress(function(event){
			if(event.keyCode==13){
				toLogin();
			}
		});
		
	</script>
</body>
</html>
